package com.gtd.account


import javax.jdo.annotations.*;
import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
class User implements Serializable {

	@PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	Key key

	@Persistent
	String username

	@Persistent
	String email

	@Persistent
	String password

	@Persistent
	Boolean active = false

	@Persistent
	Boolean deleted = false

	@Persistent
	String registeredDate

  @Persistent
  String role = "member"

  @Persistent
  String avatarUri = ""

	@Persistent
	ContactInfo contactInfo

	@Persistent(mappedBy="user")
	List<ContactGroup> contactGroups

	@Persistent(mappedBy="user")
	List<AccountSetting> accountSettings

    static constraints = {
		key nullable:true
		username blank:false
		email blank:false
		password blank:false
		active nullable:false
		deleted nullable:false
		registeredDate nullable:false
    role inList:["root", "member"]
		contactInfo nullable:true
		contactGroups nullable:true
		accountSettings nullable:true
	}
}
